home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
c_lang
/
super_c.lzh
/
TIC2.C
< prev
next >
Wrap
Text File
|
1980-01-01
|
541b
|
25 lines
#define FALSE 0
#define TRUE 1
char board[9]; /* The playing board; for each space, 0 is not used, 1 is X,
-1 is O. */
hasWon(p)
int p;
{
register int i;
register int w;
w = 3*p;
for (i = 0; i < 9; i += 3)
if ((board[i]+board[i+1]+board[i+2]) == w) return(TRUE);
for (i = 0; i < 3; i++)
if ((board[i]+board[i+3]+board[i+6]) == w) return(TRUE);
if ((board[0]+board[4]+board[8]) == w) return(TRUE);
if ((board[2]+board[4]+board[6]) == w) return(TRUE);
return(FALSE);
}